<template>
    <div class="login">
        <div style="width:100%;background-color:#302C42;">
        <headerComponent :isUserNameShow="false"></headerComponent>
      </div>
        <el-card class="box-card">
            <el-tabs class="login-tab" v-model="activeName" @tab-click="handleClick">
                <el-tab-pane label="短信登录" name="first">
                    <phone-login-component ref="phoneLogin"></phone-login-component>
                </el-tab-pane>
                <el-tab-pane label="密码登录" name="second">
                    <user-login-component ref="userLogin"></user-login-component>
                </el-tab-pane>
            </el-tabs>
        </el-card>
        <div
      style="
        display: flex;
        align-items: center;
        width: 100%;
        justify-content: center;
        background-color: #302c42;
        height: 60px;
        margin-top: 40px;
        position: fixed;
        bottom: 0px;
        z-index: 2;
      "
    >
      <span class="footer-content"
        >Copyright © All Right By
        <a style="color: white; cursor: pointer" href="#"
          >上海财才网信息科技有限公司</a
        ></span
      >
    </div>
    </div>
</template>

<script>
    import headerComponent from "../user/userComponent/headerComponent.vue"
    import phoneLoginComponent from "./loginComponent/phoneLoginComponent";
    import userLoginComponent from "./loginComponent/userLoginComponent";

    export default {
        name: "index",
        data() {
            return {
                activeName: 'first'
            };
        },
        methods: {
            handleClick(tab, event) {
                console.log(tab, event);
            }
        },
        mounted() {
            let that = this
            document.onkeydown = function (e) {
                e = window.event || e
                if(e.keyCode == 13){
                    if(that.activeName == 'first'){
                        that.$refs.phoneLogin.submitForm('loginForm');
                    }else{
                        that.$refs.userLogin.submitForm('loginForm');
                    }
                }
            }
        },
        components: {
            phoneLoginComponent,
            userLoginComponent,
            headerComponent
        }
    }
</script>

<style>
    .text {
        font-size: 14px;
    }

    .item {
        margin-bottom: 18px;
    }

    .clearfix:before,
    .clearfix:after {
        display: table;
        content: "";
    }

    .clearfix:after {
        clear: both
    }

    .box-card {
        width: 400px;
    }

    .login-tab .el-tabs__nav-wrap::after {
        height: 0px;
    }

    .login-tab .el-tabs__item {
        height: 60px;
        line-height: 60px;
        font-size: 16px;
    }

    .login-tab .el-tabs__item.is-active {
        font-weight: 600;
        color: #121212;
        font-size: 16px;
    }

    .login-tab .el-tabs__active-bar {
        height: 3px;
        background-color: #06f;
    }

    .login .box-card .el-card__body {
        padding: 0 20px 20px 20px;
    }
</style>

<style scoped>
.footer-content {
  font-size: 12px;
  color: white;
}
    .login .box-card {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        min-width: 400px;
    }

    .login {
        width: 100%;
        height: 100vh;
        background-color: #e3e3e3;
    }
</style>
